from selenium.webdriver.common.by import By

from ecshop.utils.Config import Config
from ecshop.utils.Logger import Logger

logger = Logger('Base').getlog()

class Base():
    file = '../config/config.ini'  # 文件路径为自己的包路径
    config = Config(file)

    def __init__(self,driver):
        self.driver = driver
    def open(self,usr):
        self.driver.get(usr)
        self.driver.maximize_window()

    logger.info('窗口最大化')
    def find_element(self,*locator):
        self.driver.find_element(*locator)

    def input(self,locator,text):
        self.driver.find_element(*locator).send_keys(text)
        logger.info(f'在{locator}里输入{text}')

    def click(self,locator):
        self.driver.find_element(*locator).click()
    def into_frame(self,frame):
        self.driver.switch_to.frame(frame)

    def default_frame(self):
        self.driver.switch_to.default_content()

    # def selects(self,):
    #     self.Select(find_element(*locator)).select_by_value('12')
    #
    #     Select(driver.find_element(By.NAME, 'cat_id')).select_by_value('12')






        # class Base():
        #     def __init__(self, driver):
        #         self.driver = driver
        #
        #     def open(self, url):
        #         self.driver.get(url)
        #         self.driver.maximize_window()
        #
        #     def find_element(self, *locator):
        #         self.driver.find_element(*locator)
        #
        #     def input(self, locator, text):
        #         self.find_element(*locator).send_keys(text)
        #
        #     def click(self, locator):
        #         self.find_element(*locator).click()